﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ajayumi.Platform.Search.Win
{
    public partial class SearchDropdownList : ajayumi.Platform.Search.Win.SearchControlBase
    {
        public override string DisplayText
        {
            set
            {
                this.label1.Text = value;
            }
        }

        private void SetDataSource(SearchOption[] options)
        {
            this.comboBox1.DisplayMember = "DisplayText";
            this.comboBox1.ValueMember = "Value";
            this.comboBox1.DataSource = options;
        }

        public SearchDropdownList()
        {
            InitializeComponent();
        }

        public SearchDropdownList(SearchOption[] options)
            : this()
        {
            this.SetDataSource(options);
        }

        internal override SearchItemValue GetSearchItemValue()
        {
            return new SearchItemValue()
            {
                ItemIndex = this.ItemIndex,
                Value1 = this.comboBox1.SelectedValue.ToString()
            };
        }
    }
}
